package nix.service.impl;

import java.util.List;

import nix.dao.CustomerDao;
import nix.domain.Customer;
import nix.service.CustomerService;
import nix.utils.PageBean;

import org.hibernate.criterion.DetachedCriteria;

public class CustomerServiceImpl implements CustomerService {

	private CustomerDao customerDao;

	public void setCustomerDao(CustomerDao customerDao) {
		this.customerDao = customerDao;
	}
	
	@Override
	public PageBean getPageBean(DetachedCriteria dc, Integer currentPage,
			Integer pageSize) {
		
		int totalCount = customerDao.getTotalCount(dc);
		PageBean pb = new PageBean(currentPage, totalCount, pageSize);
		List<Customer> list = customerDao.getPageList(dc, pb.getStart(), pb.getPageSize());
		pb.setList(list);
		return pb;
	}

	public void save(Customer c) {

		// 页面属性直接提交至引用对象属性（cust_source.dict_id），自动维护关系
		customerDao.savaOrUpdate(c);
	}

	@Override
	public Customer getById(Long cust_id) {
		return customerDao.getById(cust_id);
	}

	@Override
	public List<Object[]> getIndustryCount() {
		return customerDao.getIndustryCount();
	}

}
